package com.ljk.mybatis3.controller;

import com.ljk.mybatis3.entity.MybatisDynamicSqlOne;
import com.ljk.mybatis3.mapper.MybatisDynamicSqlOneMapper;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *
 * </p>
 *
 * @author ljk
 * @since 2021-12-29 21:34
 */
@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {
    @Resource
    private MybatisDynamicSqlOneMapper mybatisDynamicSqlOneMapper;

    @GetMapping("/h1")
    public Map<String, Object> h1() {
        log.info("进入h1方法");
        HashMap<String, Object> map = new HashMap<>(5);
        map.put("code", 200);
        List<MybatisDynamicSqlOne> select = mybatisDynamicSqlOneMapper.select(i -> i.limit(1));
        SqlBuilder.select(MybatisDynamicSqlOneMapper.selectList);
        map.put("data", select);
        return map;
    }
}
